package practice2;

import java.util.Random;

public class Turtle implements Runnable {
	private int route = 0;
	private String name = "Turtle";
	Random r = new Random();
	public int getRoute(){
		return route;
	}
	public void run() {
		while (route < 20) {

			int k = r.nextInt(3);
			route += k;
			System.out.println(name + " goes " + k + "meters, remain:" + (20-route));
			if (r.nextInt(5) == 1) {
				System.out.println(name + " sleep 1 s");
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}

		}

	}
}
